class Solution {
    public static int max(int x ,int y){
        if(x>y){
            return x;
        }
        return y;
    }
    public static void merge(int[] nums1, int m, int[] nums2, int n) {
        //空问题
        if(nums2 == null || nums2.length == 0){
            return;
        }

        //从后往前循环遍历 1 2 nums2.length次
        // for( int cur = ums1.length-1; cur > nums1.length-nums2.length; cur-- )
        int p1 = nums1.length-1 - nums2.length, p2 = nums2.length-1;
        int p = nums1.length - 1;

        for(int i = 0; i<nums2.length;i++){
            //哪个大哪个就放cur（nums1.length-1）处 cur--
            nums1[p] = max(nums1[p1],nums2[p2]);    //存放有点问题
            p--;
            p1--;
            p2--;
        }
    }

    public static void main(String[] args) {
        int[] arr1 = new int[]{1,2,3,0,0,0};
        int[] arr2 = new int[]{4,5,6};
        merge(arr1,3,arr2,3);
    }
}
class Solution {
    public void merge(int[] nums1, int m, int[] nums2, int n) {
        for (int i = 0; i != n; ++i) {
            nums1[m + i] = nums2[i];
        }
        Arrays.sort(nums1);
    }
}